package com.devhelper.examples.gef.figure;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;

public class EmployeeFigure extends Figure {
    private Label lblName = new Label();
    private Label lblAge = new Label();

    private XYLayout layout;

    public EmployeeFigure() {
        layout = new XYLayout();
        setLayoutManager(layout);

        add(lblName, new Rectangle(5, 5, -1, -1));
        add(lblAge, new Rectangle(5, 17, -1, -1));

        setForegroundColor(ColorConstants.darkGray);

        setBorder(new LineBorder(2));
        setOpaque(true);
    }

    public void setLayout(Rectangle rect) {
        getParent().setConstraint(this, rect);
    }

    public void setName(String name) {
        lblName.setText(name);
    }

    public void setAge(int age) {
        lblAge.setText("age : " + age);
    }
}
